<?php


namespace App\Http\Requests\Admin\Business;


use App\Exceptions\SysException;
use App\Http\Requests\BaseFormRequest;

class CardSaveFormRequest extends BaseFormRequest
{
    public function passedValidation()
    {
        $quantity = $this->get('quantity', 0);
        if ($quantity > 100000) {
            throw new SysException('一次发放不能超过10万张');
        }
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $id = $this->get('id', 0);
        return [
            'scheme_id' => [
                'required'
            ],
            'quantity' => [
                'required',
                'regex:/[1-9]\d*/'
            ]
        ];
    }

    public function attributes()
    {
        return [
            'name' => '选择制卡套餐',
            'quantity' => '制卡数量'
        ];
    }
}